import { type ComponentConfigModel } from '/@/views/formDesigner/utils';
import { useUserStore } from '/@/store/modules/user';
const userStore = useUserStore();
let serverInfo = userStore.getServerInfo;
export default {
  component: async () => await import('./InputTextarea.vue'), //import('ant-design-vue/lib/input')).Textarea
  defaultSchema: {
    label: '多行文本框',
    type: 'textarea',
    field: 'textarea',
    icon: 'epic-icon-edit',
    input: true,
    componentProps: {
      placeholder: '请输入',
    },
  },
  config: {
    attribute: [
      {
        label: '控件字段',
        type: 'input',
        field: 'name',
        componentProps: {
          placeholder: '必填项',
          require: true,
        },
      },
      {
        label: '控件名称',
        type: 'input',
        field: 'title',
        componentProps: {
          placeholder: '必填项',
          require: true,
        },
      },
      {
        label: '标签名称',
        type: 'input',
        field: 'label',
        componentProps: {
          placeholder: '必填项',
          require: true,
        },
      },
      {
        label: '长度/大小', //minT minV maxT maxV
        type: 'lenSize',
        field: 'range',
        componentProps: {
          defaultValue: {
            minT: 'd=',
            minV: '',
            maxT: 'x=',
            maxV: 100,
          },
          minTList: [
            {
              label: '>=',
              value: 'd=',
            },
            {
              label: '>',
              value: 'd',
            },
          ],
          // minVList: [
          //   {
          //     label: '当前日期',
          //     value: 'curDate',
          //   },
          // ],
          maxTList: [
            {
              label: '<=',
              value: 'x=',
            },
            {
              label: '<',
              value: 'x',
            },
          ],
          // maxVList: [
          //   {
          //     label: '当前日期',
          //     value: 'curDate',
          //   },
          // ],
        },
      },
      {
        label: '必填项',
        type: 'switch',
        field: 'canNull',
        componentProps: {
          checkedValue: false,
          unCheckedValue: true,
        },
      },
      {
        label: '输入框宽',
        type: 'EInputSize2',
        field: 'widthUnit',
        componentProps: {
          defaultValue: {
            width: 80,
            unit: '%',
          },
        },
      },
      {
        label: '输入框高',
        type: 'number',
        field: 'height',
        componentProps: {
          defaultValue: 80,
          addonAfter: 'px',
        },
      },

      {
        label: 'placeholder提示',
        type: 'input',
        field: 'placeholder',
      },
      {
        label: '显示',
        type: 'switch',
        field: 'isShow',
        componentProps: {
          defaultValue: true,
          checkedValue: true,
          unCheckedValue: false,
        },
      },
      {
        label: '只读',
        type: 'switch',
        field: 'isReadOnly',
      },
      {
        label: '只读类型',
        describe: '仅编辑引用记录时适用于”嵌套表格2“宏控件选取的记录',
        type: 'select',
        componentProps: {
          placeholder: '请选择',
          defaultValue: '',
          allowClear: true,
          options: [
            {
              label: '不限',
              value: '',
            },
            {
              label: '仅添加时',
              value: '0',
            },
            {
              label: '仅编辑时',
              value: '1',
            },
            {
              label: '仅编辑引用记录时',
              value: '2',
            },
          ],
        },
        field: 'readOnlyType',
      },
      {
        label: '提示',
        type: 'textarea',
        field: 'tip',
      },
      {
        label: '默认值类型',
        type: 'select',
        field: 'defaultType',
        componentProps: {
          defaultValue: '0',
          placeholder: '请选择',
          allowClear: true,
          options: serverInfo.isExprEnabled
            ? [
                {
                  label: '默认值',
                  value: '0',
                },
                {
                  label: '公式',
                  value: '1',
                },
              ]
            : [
                {
                  label: '默认值',
                  value: '0',
                },
              ],
        },
      },
      {
        label: '默认值',
        describe:
          '默认值以宏控件内置默认的为准，如：基础数据的默认值，如果为空，则使用此处的默认值',
        type: 'textarea',
        field: 'value',
        componentProps: {
          placeholder: '无则不填',
        },
        show: ({ values }) => values.defaultType && values.defaultType == '0',
      },
      {
        label: '公式',
        type: 'FormulaInput',
        field: 'expr',
        componentProps: {
          placeholder: '',
          require: false,
        },
        show: ({ values }) => values.defaultType && values.defaultType == '1',
      },
    ],
    event: [
      {
        type: 'input',
        describe: '输入值',
      },
      {
        type: 'change',
        describe: '值修改',
      },
      {
        type: 'pressEnter',
        describe: '按下回车的回调',
      },
      {
        type: 'focus',
        describe: '获取焦点',
      },
      {
        type: 'blur',
        describe: '失去焦点',
      },
    ],
    action: [
      {
        type: 'focus',
        describe: '使 input 获取焦点',
      },
      {
        type: 'blur',
        describe: '使 input 失去焦点',
      },
      {
        type: 'select',
        describe: '选中 input 中的文字',
      },
    ],
  },
  bindModel: 'value',
} as ComponentConfigModel;
